package com.stylefeng.guns.modular.pay.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.modular.pay.model.PayAllinBankCode;
import com.stylefeng.guns.modular.pay.service.IPayAllinBankCodeService;

/**
 * 通联银行代码控制器
 *
 * @author fengshuonan
 * @Date 2018-09-26 14:37:31
 */
@Controller
@RequestMapping("/payAllinBankCode")
public class PayAllinBankCodeController extends BaseController {

    private String PREFIX = "/pay/payAllinBankCode/";

    @Autowired
    private IPayAllinBankCodeService payAllinBankCodeService;

    /**
     * 跳转到通联银行代码首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "payAllinBankCode.html";
    }

    /**
     * 跳转到添加通联银行代码
     */
    @RequestMapping("/payAllinBankCode_add")
    public String payAllinBankCodeAdd() {
        return PREFIX + "payAllinBankCode_add.html";
    }

    /**
     * 跳转到修改通联银行代码
     */
    @RequestMapping("/payAllinBankCode_update/{payAllinBankCodeId}")
    public String payAllinBankCodeUpdate(@PathVariable Integer payAllinBankCodeId, Model model) {
        PayAllinBankCode payAllinBankCode = payAllinBankCodeService.selectById(payAllinBankCodeId);
        model.addAttribute("item",payAllinBankCode);
        LogObjectHolder.me().set(payAllinBankCode);
        return PREFIX + "payAllinBankCode_edit.html";
    }

    /**
     * 获取通联银行代码列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return payAllinBankCodeService.selectList(null);
    }

    /**
     * 新增通联银行代码
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(PayAllinBankCode payAllinBankCode) {
        payAllinBankCodeService.insert(payAllinBankCode);
        return SUCCESS_TIP;
    }

    /**
     * 删除通联银行代码
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer payAllinBankCodeId) {
        payAllinBankCodeService.deleteById(payAllinBankCodeId);
        return SUCCESS_TIP;
    }

    /**
     * 修改通联银行代码
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(PayAllinBankCode payAllinBankCode) {
        payAllinBankCodeService.updateById(payAllinBankCode);
        return SUCCESS_TIP;
    }

    /**
     * 通联银行代码详情
     */
    @RequestMapping(value = "/detail/{payAllinBankCodeId}")
    @ResponseBody
    public Object detail(@PathVariable("payAllinBankCodeId") Integer payAllinBankCodeId) {
        return payAllinBankCodeService.selectById(payAllinBankCodeId);
    }
}
